#include "onewire.h"

#define Convert 0x44
#define ROM 		0xcc
#define R_T   	0xbe

void Delay1ms(unsigned char date)		//@12.000MHz
{
	unsigned char i, j;
	while(date--)
	{
	i = 12;
	j = 169;
	do
	{
		while (--j);
	} while (--i);
}
}

void ds_convert(void)
{
	init_ds18b20();
	Delay_OneWire(1);
	Write_DS18B20(ROM);
	
	Write_DS18B20(Convert);
}

float t_return(void)
{
	static unsigned char ls = 0,ms = 0;
	float t = 0.0;int temp = 0;
	init_ds18b20();
	Delay_OneWire(1);
	Write_DS18B20(ROM);
	Write_DS18B20(R_T);
	ls = Read_DS18B20();
	ms = Read_DS18B20();
	temp = (ms<<8) | ls;
	t = temp/16.0;
	return t;
}